/**
 * 编程式导航
 */

 import React from "react";
 import { BrowserRouter as Router, Route, Link } from "react-router-dom";
 
 class Login extends React.Component {
   handleLogin = () => {
     console.log("登录成功");
     // 想跳转成功页面 ？？
   };
 
   render() {
     return (
       <div>
         <input placeholder={"用户名"}></input>
         <hr />
         <input placeholder={"密码"}></input>
         <hr />
         <button onClick={this.handleLogin}>登录</button>
       </div>
     );
   }
 }
 
 class Home extends React.Component {
   handleLogout = () => {
     console.log("登出");
     // 回到首页
   };
 
   render() {
     return (
       <div>
         你已经登录成功，精彩从这里开始。
         <hr />
         <button onClick={this.handleLogout}>登出</button>
       </div>
     );
   }
 }
 
 class App extends React.Component {
   render() {
     return (
       <Router>
         <div>
           {/* 下面的内容用默认路由匹配 */}
           <p>编程式导航：</p>
           <Link to="/login">去登录页面</Link>
           <Route path="/login" component={Login} />
           <Route path="/home" component={Home} />
         </div>
       </Router>
     );
   }
 }
 
 export default App;
 